﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace _08_多播委托_无返回值
{
    public delegate void DoSomeDelegate();
    class Person
    {
        public string Name { get; set; }
        
        public Person(string name)
        {
            this.Name = name;
        }

        public void SayHi()
        {
            Console.WriteLine("大家好，我是{0}", this.Name);
        }   
    }

    internal class Program
    {
        static void Main(string[] args)
        {
            Person p1 = new Person("张三");
            Person p2 = new Person("李四");
            Person p3 = new Person("王五");

            DoSomeDelegate doSomeDelegate = new DoSomeDelegate(p1.SayHi);
            doSomeDelegate += new DoSomeDelegate(p2.SayHi);
            doSomeDelegate += new DoSomeDelegate(p3.SayHi);

            doSomeDelegate.Invoke();

            Console.ReadKey();
        }
    }
}
